package com.zhl.study.controller;

import com.zhl.study.base.ResponseFactory;
import com.zhl.study.base.Result;
import com.zhl.study.cons.ProduckTypeConst;
import com.zhl.study.service.chainResponsibility.ProductChainFactory;
import com.zhl.study.service.chainResponsibility.ProductChainSpringFactory;
import com.zhl.study.vo.Product;
import com.zhl.study.vo.Student;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description TODO
 * @Author: z156940l@outlook.com
 * @className TestController
 * @Date: 2024/12/26 21:10
 */
@Slf4j
@RestController
@RequestMapping("api/")
@Api(value = "设计模式", tags = "设计模式")
public class TestController {

    @Autowired
    ProductChainSpringFactory<Product, Boolean> chainResponsibilityFactoryABC;
//    @Autowired
//    ProductChainSpringFactory<Student, Boolean> ChainOfResponsibilityFactoryD;
    @Autowired
    ProductChainFactory productChainFactory;

    @GetMapping("/abc")
    @ApiOperation(httpMethod = "GET", value = "责任链ABC")
    public Result<Boolean> abc() {
        Product product = new Product();
        Object o = chainResponsibilityFactoryABC.executeHandler(product);
        return ResponseFactory.ok();
    }

//    @GetMapping("/d")
//    @ApiOperation(httpMethod = "GET", value = "责任链D")
//    public Result<Boolean> d() {
//        Student student = new Student();
//        Object o = ChainOfResponsibilityFactoryD.executeHandler(student);
//        return ResponseFactory.ok();
//    }

    @GetMapping("/e")
    @ApiOperation(httpMethod = "GET", value = "责任链e")
    public Result<Boolean> e() {
        Product product = new Product();
        Object o = productChainFactory.executeHandle(product, ProduckTypeConst.PRODUCT_GENERAL);
        return ResponseFactory.ok();
    }
}
